package com.shoppingmall.controller;

import com.shoppingmall.commons.Result;
import com.shoppingmall.model.User;
import com.shoppingmall.model.UserInfo;
import com.shoppingmall.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;
    @GetMapping("/getUserList")
   public List<User> getUserList (){
      return userService.getUserList();
   }
   @PostMapping("/updateStatus")
   public Result updateStatus(int user_status,int user_id){
     userService.updateStatus(user_status,user_id);
     String message= user_status==0?"解冻":"冻结";
     return Result.success(message+"成功");
   }
    @PostMapping("/updateUser")
    public Result updateUser(@RequestBody UserInfo userInfo){
        userService.updateUser(userInfo);
        return Result.success("修改成功");
    }
    @GetMapping("/getUser")
    public UserInfo getUser(int user_id){
        return userService.getUser(user_id);
    }
}
